package com.runda.partypolicy.utils;

import java.util.regex.Pattern;

/**
 * author:  RD_YH
 * date:    2018/10/17
 * version: v1.0
 * description: 校验工具
 */
public class PatternUtils {

    private final static Pattern Mobile = Pattern
            .compile("^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\\d{8}$");

    private final static Pattern emailer = Pattern
            .compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");

    public static boolean isPhone(String phone) {
        if (phone == null || phone.trim().length() == 0) {
            return false;
        }

        return Mobile.matcher(phone).matches();
    }

    public static boolean isEmail(String email) {
        if (email == null || email.trim().length() == 0) {
            return false;
        }
        return emailer.matcher(email).matches();
    }
}
